#include <iostream>
using namespace std;

int main() {
    int m, n;
    int ripple[13] = { 0, 31,28,31,30,31,30,31,31,30,31,30,31 };
    int month = 1;
    int day = 1;
    while (cin >> m >> n)
    {
        if (m % 100 != 0 && m % 4 == 0 || m % 400 == 0)
        {
            ripple[2] = 29;
        }
        else {
            ripple[2] = 28;
        }
        while (n > ripple[month])
        {
            n -= ripple[month];
            month++;
        }
        printf("%04d-%02d-%02d\n", m, month, n);
    }
}